﻿<views:MvxWpfView 
    x:Class="Sidvall.AuthorizationManager.UI.Wpf.Views.UserView"
    xmlns:views="clr-namespace:MvvmCross.Wpf.Views;assembly=MvvmCross.Wpf"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:vms="clr-namespace:Sidvall.AuthorizationManager.UI.ViewModels;assembly=Sidvall.AuthorizationManager.UI.Identity"
    xmlns:local="clr-namespace:Sidvall.AuthorizationManager.UI.Wpf.Views" x:Name="mvxWpfView"
    xmlns:Converters="clr-namespace:Sidvall.UI.Wpf.Converters;assembly=Sidvall.UI.Wpf" 
    xmlns:Controls="clr-namespace:Sidvall.AuthorizationManager.UI.Wpf.Controls" 
    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
    xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
    mc:Ignorable="d" 
    d:DesignHeight="550" d:DesignWidth="600">

    <views:MvxWpfView.Resources>
        <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <Converters:BooleanToVisibilityConverter x:Key="NotBooleanToVisibilityConverter" Not="True"/>
        <CollectionViewSource x:Key="ResourceActions" Source="{Binding ActiveAuthorizationScope.AuthorizationScopeResourceActions}">
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="IsEnabled" Direction="Descending" />
                <scm:SortDescription PropertyName="Resources" Direction="Ascending" />
                <scm:SortDescription PropertyName="Actions" Direction="Ascending" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>
    </views:MvxWpfView.Resources>

    <Grid d:DataContext="{d:DesignInstance IsDesignTimeCreatable=True, Type={x:Type vms:UserViewModel}}">
        <Grid.RowDefinitions>
            <RowDefinition Height="0.3*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="380" />
        </Grid.RowDefinitions>

        <DataGrid x:Name="grdAuthorizationScopes" Grid.Row="0" RowHeaderWidth="0" ItemsSource="{Binding AuthorizationScopes}" AutoGenerateColumns="False" CanUserAddRows="False" 
                  CanUserResizeColumns="False" CanUserReorderColumns="False" SelectionMode="Single">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <i:InvokeCommandAction Command="{Binding ShowCommand}" CommandParameter="{Binding ElementName=grdAuthorizationScopes, Path=SelectedItem}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <DataGrid.Columns>
                <DataGridTemplateColumn Width="55" Header="Selected" SortMemberPath="IsSelected">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <i:InvokeCommandAction CommandParameter="{Binding}"
                                            Command="{Binding DataContext.SelectCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserView}}}"  />
                                    </i:EventTrigger>
                                    <i:EventTrigger EventName="Unchecked">
                                        <i:InvokeCommandAction CommandParameter="{Binding}"
                                            Command="{Binding DataContext.SelectCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserView}}}"  />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </CheckBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="*" Header="Name" SortMemberPath="Name">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding Name, Mode=OneWay, UpdateSourceTrigger=LostFocus}" IsReadOnly="True" TextWrapping="Wrap" AcceptsReturn="True" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>

        <GridSplitter Grid.Column="0" Grid.Row="1" Height="8" ResizeDirection="Rows" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />

        <Grid Grid.Row="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>

            <Controls:HeaderControl HeaderCaption="{Binding Title}" />
            <TabControl Grid.Row="1">
                <TabItem Header="Information">
                    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                        <StackPanel>
                            <StackPanel>
                                <Controls:SubHeaderControl Margin="0,5,0,0" HeaderCaption="Authorization Scope" />
                                <Grid Margin="0,5,5,0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="130" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>

                                    <Label Content="Execution Policy"/>
                                    <ComboBox Grid.Column="1" Width="300" HorizontalAlignment="Left" SelectedValuePath="Value" DisplayMemberPath="Key" SelectedValue="{Binding ActiveAuthorizationScope.ResourceItemPolicyId}" ItemsSource="{Binding ResourceItemActionPolicies}" />
                                </Grid>
                                <Grid Margin="0,5,5,0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="130" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>

                                    <Label Content="Missing user policy"/>
                                    <ComboBox Grid.Column="1" Width="300" HorizontalAlignment="Left" SelectedValuePath="Value" DisplayMemberPath="Key" SelectedValue="{Binding ActiveAuthorizationScope.MissingUserPolicyId}" ItemsSource="{Binding MissingUserPolicies}" />
                                </Grid>
                                <Grid Margin="0,5,5,0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="130" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>

                                    <Label Content="Default User Context:"/>
                                    <TextBox Grid.Column="1" Height="60" Text="{Binding ActiveAuthorizationScope.DefaultUserContext}" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" />
                                </Grid>
                                <Grid Margin="0,5,0,0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="130" />
                                        <ColumnDefinition Width="200" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>

                                    <Label Content="Require Active User"/>
                                    <CheckBox Grid.Column="1" IsChecked="{Binding ActiveAuthorizationScope.RequireActiveUser}" VerticalAlignment="Center" />
                                </Grid>
                            </StackPanel>
                            <StackPanel IsEnabled="{Binding CanEditUser}">
                                <Controls:SubHeaderControl Margin="0,5,0,0" HeaderCaption="User" />
                                <Grid Margin="0,5,0,0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="130" />
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="60" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Label Content="Created:" Height="27" VerticalAlignment="Top"/>
                                    <TextBox Grid.Column="1" Text="{Binding ActiveUser.CreatedTime}" IsReadOnly="True" Width="140" HorizontalAlignment="Left" />
                                    <Label Grid.Column="2" Content="Updated:"/>
                                    <TextBox Grid.Column="3" Text="{Binding ActiveUser.UpdatedTime}" IsReadOnly="True" Width="140" HorizontalAlignment="Left" />
                                </Grid>
                                <Grid Margin="0,5,0,0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="130" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Label Content="Accessed:"/>
                                    <TextBox Grid.Column="1" Text="{Binding ActiveUser.AccessTime}" IsReadOnly="True" Width="140" HorizontalAlignment="Left" />
                                </Grid>
                                <Grid Margin="0,5,0,0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="130" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Label Content="Active:"/>
                                    <CheckBox Grid.Column="1" IsChecked="{Binding ActiveUser.IsActive}" VerticalAlignment="Center" />
                                </Grid>
                            </StackPanel>
                        </StackPanel>
                    </ScrollViewer>
                </TabItem>
                <TabItem Header="Resource Actions">
                    <Grid>
                        <Grid Visibility="{Binding ResourceActionListIsVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <Grid>
                                <Grid.Background>
                                    <SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
                                </Grid.Background>
                                <StackPanel Orientation="Horizontal">
                                    <Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf.Identity;component/Images/Add.png" 
                                            ToolTip="Add resource action" ButtonCommand="{Binding AddResourceActionCommand}" />
                                </StackPanel>
                            </Grid>
                            <Grid Grid.Row="1" Margin="5,5,5,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="130" />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>

                                <Label Content="Default Access Level"/>
                                <ComboBox Grid.Column="1" Width="200" HorizontalAlignment="Left" SelectedValuePath="Value" DisplayMemberPath="Key" SelectedValue="{Binding ActiveAuthorizationScope.DefaultResourceActionAccessLevel}" ItemsSource="{Binding AuthorizationScopeAccessLevels}" />
                            </Grid>
                            <DataGrid Grid.Row="2" Margin="0,5,0,0" RowHeaderWidth="0" ItemsSource="{Binding Source={StaticResource ResourceActions}}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserResizeColumns="False" CanUserReorderColumns="False" SelectedItem="{Binding ActiveResourceAction}">
                                <DataGrid.Columns>
                                    <DataGridTemplateColumn Width="55" Header="Enabled" SortMemberPath="IsEnabled">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="45" Header="Items" SortMemberPath="ValidForResourceActionItems">
                                        <DataGridTemplateColumn.HeaderStyle>
                                            <Style TargetType="DataGridColumnHeader">
                                                <Setter Property="ToolTip" Value="Valid for resource items" />
                                            </Style>
                                        </DataGridTemplateColumn.HeaderStyle>
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <CheckBox IsChecked="{Binding ValidForResourceActionItems, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="120" Header="Access Level" SortMemberPath="AccessLevel">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <ComboBox IsEditable="False" ItemsSource="{Binding DataContext.ResourceAccessLevels, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserView}}}" SelectedValuePath="Value" DisplayMemberPath="Key" Text="{Binding AccessLevel, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="*" Header="Resources" SortMemberPath="Resources">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Resources, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" AcceptsReturn="True" />
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="*" Header="Actions" SortMemberPath="Actions">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <ComboBox IsEditable="True" ItemsSource="{Binding DataContext.ResourceActionOptions, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserView}}}" DisplayMemberPath="Name" SelectedValuePath="Name" Text="{Binding Actions, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" ToolTip="{Binding Actions}" />
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="*" Header="Sub Actions" SortMemberPath="SubActions">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding SubActions, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" AcceptsReturn="True" />
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="50" Header="Claims" SortMemberPath="AuthorizationScopeResourceActionClaims.Count">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding AuthorizationScopeResourceActionClaims.Count}" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="35" IsReadOnly="True">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Controls:ButtonControl ImageHeight="32" ImageWidth="32" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf.Identity;component/Images/Edit.png" 
                                                        ButtonCommand="{Binding DataContext.EditClaimsCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserView}}}" 
                                                        ButtonCommandParameter="{Binding}" ToolTip="Edit claims" IsEnabled="{Binding CanEditClaims}" />
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="35" IsReadOnly="True">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Button Width="32" Height="32" Background="{x:Null}" BorderBrush="{x:Null}" 
                                                            Command="{Binding DataContext.DeleteResourceActionCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserView}}}"
                                                            CommandParameter="{Binding}">
                                                    <Image Source="/Sidvall.AuthorizationManager.UI.Wpf.Identity;component/Images/Delete.png" ToolTip="Delete resource action" />
                                                </Button>
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                </DataGrid.Columns>
                            </DataGrid>
                        </Grid>
                        <Grid Visibility="{Binding ResourceActionListIsVisible, Converter={StaticResource NotBooleanToVisibilityConverter}}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <Grid Grid.ColumnSpan="3">
                                <Grid.Background>
                                    <SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
                                </Grid.Background>
                                <StackPanel Orientation="Horizontal">
                                    <Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf.Identity;component/Images/Back.png" 
                                            ToolTip="Back to list" ButtonCommand="{Binding ShowResourceActionListCommand}" />
                                    <Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf.Identity;component/Images/Add.png" 
                                            ToolTip="Add claim" ButtonCommand="{Binding AddClaimCommand}" />
                                </StackPanel>
                            </Grid>
                            <DataGrid Grid.Row="1" RowHeaderWidth="0" ItemsSource="{Binding ActiveResourceAction.AuthorizationScopeResourceActionClaims}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserResizeColumns="False" CanUserReorderColumns="False" CanUserResizeRows="False" RowHeight="50">
                                <DataGrid.Columns>
                                    <DataGridTemplateColumn Width="60" Header="Enabled">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="*" Header="ClaimType">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <ComboBox IsEditable="True" ItemsSource="{Binding DataContext.ValidClaims, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserView}}}" DisplayMemberPath="ClaimType" SelectedValuePath="ClaimType" Text="{Binding ClaimType, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" />
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="150" Header="Comparison">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <ComboBox SelectedValuePath="Value" DisplayMemberPath="Key" SelectedValue="{Binding ComparisonOperator, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.ComparisonOperators, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserView}}}" />
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="150" Header="Value">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" AcceptsReturn="True" />
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="35" IsReadOnly="True">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Button Width="32" Height="32" Background="{x:Null}" BorderBrush="{x:Null}" 
                                                            Command="{Binding DataContext.DeleteClaimCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserView}}}"
                                                            CommandParameter="{Binding}">
                                                    <Image Source="/Sidvall.AuthorizationManager.UI.Wpf.Identity;component/Images/Delete.png" ToolTip="Delete claim" />
                                                </Button>
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                </DataGrid.Columns>
                            </DataGrid>
                        </Grid>
                    </Grid>
                </TabItem>
                <TabItem Header="User Claims">
                    <Grid IsEnabled="{Binding CanEditUser}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid>
                            <Grid.Background>
                                <SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
                            </Grid.Background>
                            <StackPanel Orientation="Horizontal">
                                <Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf.Identity;component/Images/Add.png" 
                                            ToolTip="Add user claim" ButtonCommand="{Binding AddUserClaimCommand}" />
                            </StackPanel>
                        </Grid>
                        <DataGrid Grid.Row="1" RowHeaderWidth="0" ItemsSource="{Binding ActiveUserClaims}" AutoGenerateColumns="False" CanUserResizeColumns="False" CanUserReorderColumns="False" CanUserAddRows="False">
                            <DataGrid.Columns>
                                <DataGridTemplateColumn Width="*" Header="Type">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <ComboBox IsEditable="True" ItemsSource="{Binding DataContext.ValidUserClaims, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserView}}}" DisplayMemberPath="ClaimType" SelectedValuePath="ClaimType" Text="{Binding ClaimType, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" />
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                                <DataGridTemplateColumn Width="150" Header="Value">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBox Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" AcceptsReturn="True" />
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                                <DataGridTemplateColumn Width="35" IsReadOnly="True">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button ToolTip="Delete user claim" CommandParameter="{Binding}"
                                            Command="{Binding DataContext.DeleteUserClaimCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserView}}}">
                                                <Image Source="/Sidvall.AuthorizationManager.UI.Wpf.Identity;component/Images/Delete.png" Width="24"/>
                                            </Button>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>
                    </Grid>
                </TabItem>
                <TabItem Header="User Context">
                    <Grid IsEnabled="{Binding CanEditUser}">
                        <TextBox Text="{Binding ActiveUserContext}" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" />
                    </Grid>
                </TabItem>
            </TabControl>
        </Grid>
    </Grid>
</views:MvxWpfView>
